﻿using System;

namespace HandleArray {
    class Program {
        static int GetArrayMaximum(int[] array) {
            int maxNum = array[0];
            foreach (int num in array) {
                if (maxNum < num) {
                    maxNum = num;
                }
            }
            return maxNum;
        }
        static int GetArrayMinimum(int[] array) {
            int minNum = array[0];
            foreach (int num in array) {
                if (num < minNum) {
                    minNum = num;
                }
            }
            return minNum;
        }
        static int GetArraySum(int[] array) {
            int sum = 0;
            foreach (int num in array) {
                sum += num;
            }
            return sum;
        }
        static double GetArrayAverage(int[] array) {
            return (double)GetArraySum(array) / array.Length;
        }
        static void Main(string[] args) {
            int elementNumber = 0;
            do {
                Console.WriteLine("Input(Number of Elements)(Positive Integer):");
                try {
                    elementNumber = int.Parse(Console.ReadLine());
                }
                catch (Exception e) {
                    Console.WriteLine(e);
                }
            } while (elementNumber <= 0);
            int[] array = new int[elementNumber];
            for (int index = 0; index < elementNumber; index++) {
                do {
                    Console.WriteLine($"Input(Element {index + 1})(Positive Integer):");
                    try {
                        array[index] = int.Parse(Console.ReadLine());
                    }
                    catch (Exception e) {
                        Console.WriteLine(e);
                    }
                } while (array[index] <= 0);
            }
            Console.WriteLine("Maximum:" + GetArrayMaximum(array));
            Console.WriteLine("Minimum:" + GetArrayMinimum(array));
            Console.WriteLine("Sum:" + GetArraySum(array));
            Console.WriteLine("Average:" + GetArrayAverage(array));
        }
    }
}
